package co.th.helper.jdbc.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import co.th.helper.jdbc.RowMapper;
import co.th.helper.model.Person;

public class PersonRowMapper extends RowMapper<Person>{

	@Override
	public Person mapRow(ResultSet resultSet) throws SQLException {
		Person person = new Person();
		
		if (isThere(resultSet, "person_code"))
			person.setPersonCode(resultSet.getBigDecimal("person_code"));
		
		if (isThere(resultSet, "person_title"))
			person.setPersonTitle(resultSet.getString("person_title"));
		
		if (isThere(resultSet, "person_first_name"))
			person.setPersonFirstName(resultSet.getString("person_first_name"));
		
		if (isThere(resultSet, "person_last_name"))
			person.setPersonLastName(resultSet.getString("person_last_name"));
		
		if (isThere(resultSet, "person_type"))
			person.setPersonType(resultSet.getBigDecimal("person_type"));
		
		if (isThere(resultSet, "telephone"))
			person.setTelephone(resultSet.getString("telephone"));
		
		if (isThere(resultSet, "email"))
			person.setEmail(resultSet.getString("email"));
		
		if (isThere(resultSet, "imp_code"))
			person.setImp(resultSet.getBigDecimal("imp_code"));
		
		if (isThere(resultSet, "rp_code"))
			person.setRp(resultSet.getBigDecimal("rp_code"));
		
		if (isThere(resultSet, "remark"))
			person.setRemark(resultSet.getString("remark"));
		
		if (isThere(resultSet, "create_by"))
			person.setCreateBy(resultSet.getString("create_by"));
		
		if (isThere(resultSet, "create_date"))
			person.setCreateDate(resultSet.getDate("create_date"));
		
		if (isThere(resultSet, "update_by"))
			person.setUpdateBy(resultSet.getString("update_by"));
		
		if (isThere(resultSet, "update_date"))
			person.setUpdateDate(resultSet.getDate("update_date"));
		
		return person;
	}

}
